﻿Ext.define('Admin.view.leave.LeaveGrid', {
	extend: 'Ext.grid.Panel',
	id: 'leave-grid',
	xtype: 'leave-grid',
	title: '我的请假记录',
	iconCls: 'x-fa fa-arrow-circle-o-up',
	//cls: 'user-grid',


	bind: '{leaveGridStore}',		//viewModeld的store
	//sm:new Ext.grid.CheckboxSelectionModel(),
	columns: [
		{ header: '工号', dataIndex: 'userId', width: 60, sortable: true }
		, { header: '开始时间', dataIndex: 'startTime', width: 150, sortable: true, renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s') }
		, { header: '结束时间', dataIndex: 'endTime', width: 150, sortable: true, renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s') }
		//,{header: 'realityStartTime' 	,dataIndex: 'realityStartTime',width: 60,sortable: true,renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s')}
		//,{header: 'realityEndTime' 	,dataIndex: 'realityEndTime',width: 60,sortable: true,renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s')}
		//,{header: 'applyTime' 	,dataIndex: 'applyTime',width: 180,sortable: true,renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s')}
		, { header: '请假等级', dataIndex: 'leaveType', width: 80, sortable: true }
		, { header: '请假原因', dataIndex: 'reason', width: 180, sortable: true }
		// ,{header: 'processInstanceId' ,dataIndex: 'processInstanceId',width: 180,sortable: true}
		, { header: '状态', dataIndex: 'state', width: 90, sortable: true }
		, {
			text: '操作',
			xtype: 'actioncolumn',
			items: [{
				xtype: 'button',
				iconCls: 'x-fa fa-pencil',
				tooltip: '调整申请',
				getClass: function (v, meta, rec) {
					if (rec.get('state') != '申请被驳回') {
						return 'x-hidden';
					}
					return 'x-fa fa-gear';
				},
				handler: 'onClickLeaveApproveCompleteWindowButton'
			}, {
				xtype: 'button',
				iconCls: 'x-fa fa-pencil',
				tooltip: '销假',
				getClass: function (v, meta, rec) {
					if (rec.get('state') != '已通过审批') {
						return 'x-hidden';
					}
					return 'x-fa fa-times-circle';
				},
				handler: 'onClickLeaveApproveCompleteWindowButton'
			}]
		}
	],
	
	dockedItems: [{
		xtype: 'pagingtoolbar',
		dock: 'bottom',
		bind: '{leaveGridStore}',	//viewModeld的store
		displayInfo: true,
		displayMsg: '显示第 {0} - {1} 条数据 总计 {2}',
		emptyMsg: "没有任何数据",
		items: ['-', {
			tooltip: '添加',
			iconCls: 'x-fa fa-plus',
			listeners: {
				click: 'onClickLeaveGridAddButton'
			}
		}, '-', {
				tooltip: '修改',
				iconCls: 'x-fa fa-pencil',
				listeners: {
					click: 'onClickLeaveGridUpdateButton'
				}
			}, '-', {
				tooltip: '删除',
				iconCls: 'x-fa fa-close',
				listeners: {
					click: 'onClickLeaveGridDeleteButton'
				}
			}, '-', {
				tooltip: '申请审批',
				iconCls: 'x-fa fa-arrow-up',
				listeners: {
					click: 'onClickStartButton'
				}
			}]
	}]
});
